//
//  ZLLayout.swift
//  jingxin
//
//  Created by Yuki on 2020/8/10.
//  Copyright © 2020 Zl. All rights reserved.
//  UIView的扩展类 有问题

import UIKit



extension UIView {
    
    //左间距
    public var zl_left :CGFloat{
        get {
            return self.frame.origin.x;
        }
        set (newLeft){
            var frame = self.frame;
            frame.origin.x = newLeft;
            self.frame = frame;
        }
    }
    
    //上间距
    public var zl_top :CGFloat{
        get{
            return self.frame.origin.y;
        }
        set (newTop){
            var frame = self.frame;
            frame.origin.y = newTop;
            self.frame = frame;
        }
    }
    
    //右边
    public var zl_right :CGFloat{
        get{
            return self.frame.origin.x + self.frame.size.width;
        }
        
        set(newRight){
            var frame = self.frame;
            frame.origin.x = newRight - self.frame.size.width;
            self.frame = frame;
        }
    }
    
    /**  底部  **/
    public var zl_bottom :CGFloat{
        get{
            return self.frame.origin.y + self.frame.size.height;
        }
        set (newBottom){
            var frame = self.frame;
            frame.origin.y = newBottom - self.frame.size.height;
            self.frame = frame;
        }
    }
    
    /**  中心x  **/
    public var zl_centerX :CGFloat{
        get {
            return self.center.x;
        }
        
        set (newCenterX){
            self.center = CGPoint.init(x: newCenterX, y: self.center.y);
        }
    }
    
    /**  中心x  **/
    public var zl_centerY :CGFloat{
        get {
            return self.center.y;
        }
        
        set (newCenterY){
            self.center = CGPoint.init(x: self.center.x, y: newCenterY);
        }
    }
    
    /**  宽度  **/
    public var zl_width :CGFloat{
        get {
            return self.frame.size.width;
        }
        set (newWidth){
            var frame = self.frame;
            frame.size.width = newWidth;
            self.frame = frame;
        }
    }
    
    /**  高度  **/
    public var zl_height :CGFloat{
        get {
            return self.frame.size.height;
        }
        set (newHeight){
            var frame = self.frame;
            frame.size.height = newHeight;
            self.frame = frame;
        }
    }
    
    
}
